import React from 'react';
import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import axios from 'axios';

const FileUpload = () => {
    const handleChange = async (info) => {
        if (info.file.status === 'done') {
            message.success(`${info.file.name}文件上传成功`);
        } else if (info.file.status === 'error') {
            message.error(`${info.file.name}文件上传失败`);
        }
    };

    return (
        <Upload
            action="/api/files/"
            onChange={handleChange}
            showUploadList={false}
        >
            <Button icon={<UploadOutlined />}>上传文件</Button>
        </Upload>
    );
};
